package com.example.demo.api.controller;

import com.example.demo.api.dto.StudentGradeDTO;
import com.example.demo.app.service.GradesService;
import com.example.demo.domain.entity.Grades;
import com.example.demo.domain.vo.StudentGradesSimpleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/grades")
public class GradesController {
    @Autowired
    private GradesService gradesService;

    @GetMapping
    public List<StudentGradeDTO> get(Integer studentId, Integer teacherId, Integer courseId){
        return gradesService.queryGradesByCondition(studentId, teacherId, courseId);
    }

    @DeleteMapping
    public Integer deleteByIds(@RequestBody List<Integer> ids){
        System.out.println(ids);
        return gradesService.deleteByStudentIdInteger(ids);
    }

    @GetMapping("/grades")
    public List<StudentGradesSimpleVo> grades(){
        return gradesService.queryStudentGradesSimple();
    }


}
